package com.itheima.thread;

public class Demo05 {

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            for (int i=0;i<100;i++) {
                try {
                    Thread.sleep(1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                String name = Thread.currentThread().getName();
                System.out.println(
                        name+i
                );
            }
        });
        t1.setName("女神");
        Thread t2 = new Thread(() -> {
            for (int i=0;i<100;i++) {
                try {
                    Thread.sleep(1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                String name = Thread.currentThread().getName();
                System.out.println(
                        name+i
                );
            }
        });
        t2.setName("备胎");
        t2.setDaemon(true);
        t1.setDaemon(true);
        t1.start();
        t2.start();
        for (int i = 0; i < 10; i++) {
            Thread.sleep(1);
            System.out.println("main"+i);
        }
    }
}
